import {defineConfig} from "vite";
import {resolve} from "path";
import vue from "@vitejs/plugin-vue";
import Components from "unplugin-vue-components/vite";
import AutoImport from "unplugin-auto-import/vite";
import {VitePWA} from "vite-plugin-pwa";
import viteCompression from "vite-plugin-compression";

import {ElementPlusResolver} from "unplugin-vue-components/resolvers";
// https://vitejs.dev/config/
export default ({mode}) =>
    defineConfig({
        plugins: [
            vue(),
            AutoImport({
                imports: ["vue"],
                resolvers: [ElementPlusResolver()],
            }),
            Components({
                resolvers: [ElementPlusResolver()],
            }),
        ],
        server: {
            port: "5527",
            open: true,
            proxy: {
                // Add your proxy configuration here
                '/api/otherCom': {
                    target: 'http://120.26.13.200:5528',
                    // target: 'http://localhost:5528', // Replace with your actual API server URL
                    changeOrigin: true
                }
            },
            cors: true // Enable CORS
        },
        resolve: {
            alias: [
                {
                    find: "@",
                    replacement: resolve(__dirname, "src"),
                },
            ],
        },
        css: {
            preprocessorOptions: {
                scss: {
                    charset: false,
                    additionalData: `@import "./src/style/global.scss";`,
                },
            },
        },
    });
